#include <iostream>
#include <stack>
#include <string>
using namespace std;

const int kMaxM = 1200;

int h[kMaxM];
int l[kMaxM], r[kMaxM];

int GetMaxRect(int m) {
  int ret = 0;
  stack<int> s;

  h[0] = -1;
  s.push(0);
  for (int i = 1; i <= m; i++) {
    r[i] = m + 1;
    for (; h[s.top()] >= h[i]; s.pop()) {
      r[s.top()] = i;
    }
    l[i] = s.top();
    s.push(i);
  }
  for (int i = 1; i <= m; i++) {
    ret = max(ret, h[i] * (r[i] - l[i] - 1));
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int ans = 0;
  int n, m;
  string s;

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> s;
      if (s == "F") {
        h[j]++;
      } else {
        h[j] = 0;
      }
    }
    ans = max(GetMaxRect(m), ans);
  }
  cout << ans * 3 << "\n";
  return 0;
}
